package application;

import java.io.IOException;
import java.io.ObjectStreamException;
import java.io.Serializable;


public class UniqueFileID implements Serializable{

	private static final long serialVersionUID = 5036211764174036136L;
	private String filename = null;
	private String peerName = null;
	private long size = 0;
	
	public UniqueFileID( String filename, String peerName, int size ) {
		this.peerName = peerName;
		this.filename = filename;
		this.size = size;
	}

	public MachineID getMachineID(){
		return MachineIDProvider.getInstance().getMachineID(peerName);
	}
	
	public String getFileName() {
		return filename;
	}

	public long getSize() {
		return size;
	}
	
	public String toString(){
		return filename;
	}
	
	private void writeObject(java.io.ObjectOutputStream out)
	throws IOException{
		out.writeObject(filename);
		out.writeObject(new Long(size));
		out.writeObject(peerName);
	}
	
	private void readObject(java.io.ObjectInputStream in)
	throws IOException, ClassNotFoundException{
		filename = (String) in.readObject();
		size = (Long) in.readObject();
		peerName = (String)in.readObject();
	}
	
	@SuppressWarnings("unused")
	private void readObjectNoData() throws ObjectStreamException{
		filename = "";
		peerName="";
		size = 0;
	}
}
